package org.gitos.cloud.comet.logic;

import io.netty.channel.ChannelHandlerContext;
import org.gitos.cloud.domain.comm.Constant;
import org.gitos.cloud.domain.tcp.Bucket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by shizhengchu on 15/12/7.
 * 必须单例模式
 */
@Component
public class LogicLoop {
    private static Logger log = LoggerFactory.getLogger(LogicLoop.class);

    public static ExecutorService fixThreadPool = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);

    @Autowired
    InitContextHandler initContextHandler;

    @Value("${" + Constant.NODE_ID + "}")
    private String nodeId;


    /**
     * 进入线程池
     *
     * @param bucket
     */
    public void pushJob(Bucket bucket) {
        initContextHandler.tcpHandler(bucket).fireTcplogic();
    }

}
